<?php
include '../config.php';

$id = $_GET["id"];

$mysqli = new mysqli($MYSQL_HOST, $MYSQL_USERNAME, $MYSQL_PASSWORD, $MYSQL_DB_NAME);
if ($mysqli->connect_errno) {
	echo "ERR";
} else {
	$mysqli->set_charset("utf8");
	$query = "SELECT `idCategoria` FROM `categoria` WHERE `idCategoria`='" . $id . "'";
	$verify = $mysqli->query($query);
	if (!$verify) {
		mysqli_free_result($verify);
		$mysqli->close();
		echo "ERR";
	} else {
		if ($verify->num_rows) {
			$query = "DELETE FROM `categoria` WHERE `idCategoria`='" . $id . "'";
			$verify = $mysqli->query($query);
			if (!$verify) {
				mysqli_free_result($verify);
				$mysqli->close();
				echo "ERR";
			} else {
				mysqli_free_result($verify);
				$mysqli->close();
				echo "OK";
			}
		} else {
			mysqli_free_result($verify);
			$mysqli->close();
			echo "ERR";
		}
	}
}
?>
